import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

export const columns: BasicColumn[] = [
  {
    title: '机构名称',
    dataIndex: 'name',
    width: 220,
    align: 'left',
  },
  {
    title: '排序',
    dataIndex: 'orderFlag',
    width: 100,
  },
  {
    title: '机构编码',
    dataIndex: 'branchCode',
    width: 160,
    align: 'left',
  },
  {
    title: '机构主管',
    dataIndex: 'manager',
    width: 160,
    slots: { customRender: 'manager' },
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
  },
  {
    title: '备注',
    dataIndex: 'memo',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '机构名称',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'branchCode',
    label: '机构编码',
    component: 'Input',
    colProps: { span: 8 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'branchInnercode',
    label: 'id',
    component: 'Input',
    required: false,
    show: false,
  },
  {
    field: 'name',
    label: '部门名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'parentInnercode',
    label: '上级部门',
    component: 'TreeSelect',
    show: ({ values }) => {
      return values.parentInnercode !== '0000';
    },
    required: true,
  },
  {
    field: 'orderFlag',
    label: '排序',
    component: 'InputNumber',
    required: true,
  },
  {
    field: 'branchCode',
    label: '编号',
    component: 'Input',
    required: true,
  },
  {
    field: 'manager',
    label: '机构主管',
    component: 'Select',
    componentProps: {
      mode: 'multiple',
      options: [],
    },
    required: false,
  },
  {
    field: 'phone',
    label: '电话',
    component: 'Input',
    required: false,
  },
  {
    field: 'fax',
    label: '传真',
    component: 'Input',
    required: false,
  },
  {
    label: '备注',
    field: 'memo',
    component: 'InputTextArea',
  },
];
